package com.example.shixunandjavagotoyangchen.BoosYang.Day002;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.example.modelviewpresenter.View.BasterFragment;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1104.WomenswearAdpter;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1104.WomenswearBean;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1104.WomenswearContion;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1104.WomenswearModel;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1104.WomenswearPresenter;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1105.HighstreetAdpter;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1105.HighstreetBean;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1105.HighstreetContion;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1105.HighstreetModel;
import com.example.shixunandjavagotoyangchen.BoosYang.Day002.Day002_1105.HighstreetPresenter;
import com.example.shixunandjavagotoyangchen.R;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;
import com.scwang.smart.refresh.layout.api.RefreshLayout;
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener;

import java.util.List;


public class BlankFragmentDay002_1105 extends BasterFragment implements OnRefreshLoadMoreListener, HighstreetContion.vier {


    public static SmartRefreshLayout HighstreetSmartRefreshLayout;
    private RecyclerView HighstreetRecyclerView;
    public boolean isning=true;
    public HighstreetAdpter adpter;
    public HighstreetPresenter presenter;


    @Override
    public int BandLayout() {
        return R.layout.fragment_blank_fragment_day002_1105;
    }

    @Override
    public void initView() {

        HighstreetSmartRefreshLayout = (SmartRefreshLayout) findViewById(R.id.Highstreet_SmartRefreshLayout);
        HighstreetRecyclerView = (RecyclerView) findViewById(R.id.Highstreet_RecyclerView);

        HighstreetRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.VERTICAL));
        HighstreetSmartRefreshLayout.setOnRefreshLoadMoreListener(this);
        presenter = new HighstreetPresenter(this,new HighstreetModel());
        presenter.highstreeing("Home_zidingyi.php");


    }

    @Override
    public void initDate() {

    }



    @Override
    public void getvier(List<HighstreetBean.ShujuBean> dataBeans) {
        HighstreetSmartRefreshLayout.finishLoadMore();
        HighstreetSmartRefreshLayout.finishRefresh();
        if (adpter==null){
            adpter = new HighstreetAdpter(dataBeans);
            HighstreetRecyclerView.setAdapter(adpter);
        }else {
            if (isning){
                adpter.getData().clear();
            }
            adpter.getData().addAll(dataBeans);
            adpter.notifyDataSetChanged();
        }
    }

    @Override
    public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
        isning =false;
        refreshLayout.finishLoadMore();
        refreshLayout.finishRefresh();
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {

        if (isning){
            Log.i("aaa","la1");
        }
        refreshLayout.finishLoadMore();
        refreshLayout.finishRefresh();
    }


}
